﻿#region Copyright 
/*-------------------------------------------------------------------------
* 命名空间名称/文件名:    SSPivot.Admin.Core.Service.sys.Permission/ISysPermissionService 
* CLR版本:     4.0.30319.42000
* 机器名称:    DESKTOP-NHMLO8A
* 功 能：       N/A
* 类 名：       ISysPermissionService
* 创建时间：  2025/6/4 17:35:58
* 版本号：      v1.0
* 创建人:        xulong
*-------------------------------------------------------------------------*/
#endregion
using SSPivot.Admin.Core.Service.sys.Permission.Dto;
using SSPivot.AspNetCore.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.Admin.Core.Service.sys.Permission
{
    /// <summary>
    /// 权限服务
    /// </summary>
    public interface ISysPermissionService : IApplicationService
    {
        #region 服务


        /// <summary>
        /// 查询分组
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<PermissionGetGroupDto> GetGroupAsync(long id);

        /// <summary>
        /// 查询菜单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<PermissionGetMenuDto> GetMenuAsync(long id);

        /// <summary>
        /// 查询权限点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<PermissionGetDotDto> GetDotAsync(long id);

        /// <summary>
        /// 查询权限列表
        /// </summary>
        /// <param name="key"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        Task<List<PermissionListDto>> GetListAsync(QuerySysPermissionRequest model);
        /// <summary>
        /// 查询授权权限列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<dynamic>> GetPermissionListAsync();

        /// <summary>
        /// 查询角色权限列表
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        Task<List<long>> GetRolePermissionListAsync(long roleId = 0);

        ///// <summary>
        ///// 查询租户权限列表
        ///// </summary>
        ///// <param name="tenantId"></param>
        ///// <returns></returns>
        //[Obsolete("请使用查询套餐权限列表PkgService.GetPkgPermissionListAsync")]
        //Task<List<long>> GetTenantPermissionListAsync(long tenantId);
        /// <summary>
        /// 新增分组
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<long> AddGroupAsync(PermissionAddGroupDto input);
        /// <summary>
        /// 新增菜单
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<long> AddMenuAsync(PermissionAddMenuDto input);
        /// <summary>
        /// 新增接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<long> AddApiAsync(PermissionAddApiDto input);
        /// <summary>
        /// 新增权限点
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns> 
        Task<long> AddDotAsync(PermissionAddDotDto model);
        /// <summary>
        /// 修改分组
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task UpdateGroupAsync(PermissionUpdateGroupDto input);

        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task UpdateMenuAsync(PermissionUpdateMenuDto input);
        /// <summary>
        /// 修改权限点
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns> 
        Task UpdateDotAsync(PermissionUpdateDotDto input);

        /// <summary>
        /// 彻底删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>  
        Task DeleteAsync(long id);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task SoftDeleteAsync(long id);
        /// <summary>
        /// 保存角色权限
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>   
        Task AssignAsync(PermissionAssignDto model);

        /// <summary>
        /// 保存租户权限
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>    
        [Obsolete("请使用设置套餐权限PkgService.SetPkgPermissionsAsync")]
        Task SaveTenantPermissionsAsync(PermissionSaveTenantPermissionsDto model);
        #endregion

        #region tree

        /// <summary>
        /// 获得本级和下级Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<List<long>> GetChildrenIdListAsync(long id);

        /// <summary>
        /// 获取上级
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        Task<List<SysPermissionDto>> GetSupCategory(long id);

        /// <summary>
        /// 获取上级名称
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        Task<List<string>> GetSupCategoryName(long id);

        /// <summary>
        /// 获取下级部门带层级
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        Task<List<SysPermissionDto>> GetSubCategoryTreeAsync(QuerySysPermissionRequest model);

        /// <summary>
        /// 获取类别tree
        /// </summary>
        /// <returns></returns>
        Task<List<SysPermissionDto>> GetAllDataTreeAsync(QuerySysPermissionRequest model);
        /// <summary>
        /// 递归获取所有子级部门及层级
        /// </summary>
        /// <param name="model"></param>
        SysPermissionDto RecursionCategory(SysPermissionDto model, List<SysPermissionDto> allData);
        #endregion
    }
}
